package org.example.route.controller.UserController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.example.route.model.dto.BaseRequest;
import org.example.route.model.pojo.Result;
import org.example.route.model.vo.OrderShowVO;
import org.example.route.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/user/order")
@Slf4j
@Tag(name = "用户订单管理")
//TODO 可能为了实现时间功能，还是要在此表加上创建时间（create_time）这个属性
public class OrderController {

    //查看所有订单，包括历史订单等
    @Autowired
    private OrderService orderService;

    @Operation(summary = "查看所有订单，包括历史订单等")
    @PostMapping("/list")
    public Result<List<OrderShowVO>> list()
    {
         log.info("查看所有订单，包括历史订单等");
        List<OrderShowVO> orderShowVOList = orderService.list();
        return Result.success(orderShowVOList);
    }


    /**完成二测**/
    @Operation(summary = "取消订单")
    @PostMapping("/cancel")
    public Result cancel(@RequestBody BaseRequest baseRequest)
    {
        log.info("取消订单,{}",baseRequest.getKey());
        orderService.cancel(baseRequest);
        return Result.success();

    }



}
